// #packager-optimize

(function() {

    var domModule = {

        swapNodes : function(node1, node2) {
            var temp = node1.parentNode.insertBefore(document.createTextNode(''), node1);

            node2.parentNode.insertBefore(node1, node2);
            temp.parentNode.insertBefore(node2, temp);
            temp.parentNode.removeChild(temp);
        },

        parent : function(node, className, maxIterations) {
            var parent = node, iteraton = 0;

            while (parent != null) {
                var parentClassName = parent.className;

                if (parentClassName) {
                    var index = parentClassName.indexOf(className);

                    if (index != -1) {
                        var nextChar = parentClassName.charAt(index + className.length);
                        if ((nextChar == ' ') || (nextChar == '')) return parent;
                    }
                }

                ++iteraton;
                if ( maxIterations && (iteraton == maxIterations) ) break;

                parent = parent.parentNode;
            }

            return null;
        }

    };

    juliet.registerModule('juliet.core', 'dom-0.1', domModule);

})();
